﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharePoint.Contrib;
using NUnit.Framework;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Xml.Linq;
using System.IO;
using System.Configuration;
using System.Web.Configuration;

namespace NUnit.SharePointContrib
{
    [TestFixture]
    public class WebConfigManagerTest
    {
        SPSite sitecollection = null;
        SPWebApplication webapplication = null;
        const string OWNER = "SharePointContrib";

        [SetUp]
        public void Init()
        {

            if (SharePoint.TryFindSiteCollection(out sitecollection))
            {
                webapplication = sitecollection.WebApplication;
            }
        }

        [TearDown]
        public void Dispose()
        {
            sitecollection.Dispose();
        }

        private XDocument LoadFromConfig(string name)
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), string.Concat(@"Files\", name, ".config"));
            return XDocument.Load(path);
        }

        private ConfigurationSection SectionFromWebConfig(string sectionpath)
        {
            Configuration config = WebConfigurationManager.OpenWebConfiguration("/", webapplication.Name);
            var section = config.GetSection(sectionpath);
            return section;
        }


    }
}
